import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-contract-stop',
  templateUrl: './contract-stop.component.html',
  styleUrls: ['./contract-stop.component.scss']
})
export class ContractStopComponent implements OnInit {
  public costList = [];
  
  public listCount = 10;
  constructor() { }

  ngOnInit() {
    this.costList = [];
    for (var i = 1; i <= this.listCount; i++) {
      var username = ['易方达信用债券A','平安证券对冲1号','东方证券对冲1号','华福证券对冲1号','安信证券对冲1号'];
      var stopway = ['提前终止','到期终止'];
      var shenhe = ['已审核', '待审核'];
      var usertype = ['养老金产品','社保基金','养老金','年金','公募','一对一','一对多'];
      var ramdom3 = Math.round(Math.random() * 6);
      var ramdom = Math.round(Math.random() * 2);
      var ramdom2 = Math.round(Math.random());
      this.costList.push({
        code: 'QDZH000' + i,
        name: '账户名称' + i,
        startDate: "2008-06-01",
        stopDate: '2017-9-30',
        type: '养老金',
        money: '10000' + i,
        username:username[ramdom],
        stopway:stopway[ramdom2],
        shenhe:shenhe[ramdom2],
        usertype:usertype[ramdom3]
      });
    }
  }
  showDetail(){
    window['$'](".modal-detail").modal('show');
  }
  showHisListModal() {
    window['$']("#detail-his-list-modal").modal();
  }
  ngAfterViewInit() {
    //Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
    //Add 'implements AfterViewInit' to the class.
    window['$']('input').iCheck({
      checkboxClass: 'icheckbox_flat-blue',
      radioClass: 'iradio_flat-blue'
    });
    //(综合查询)全选、全反选
    window['$']('#checkAll').on('ifChecked ifUnchecked', function (event) {
      if (event.type == 'ifChecked') {
        window['$']('.subcb').iCheck('check');
      } else {
        window['$']('.subcb').iCheck('uncheck');
      }
    });

    window['$']('.subcb').on('ifChanged', function (event) {
      if (window['$']('.subcb').filter(':checked').length == window['$']('.subcb').length) {
        window['$']('#checkAll').prop('checked', 'checked');
      } else {
        window['$']('#checkAll').prop('checked', false);
      }
      window['$']('#checkAll').iCheck('update');
    });
    //(受托人附件)全选、全反选
    window['$']('#checkAll1').on('ifChecked ifUnchecked', function (event) {
      if (event.type == 'ifChecked') {
        window['$']('.subcb1').iCheck('check');
      } else {
        window['$']('.subcb1').iCheck('uncheck');
      }
    });

    window['$']('.subcb1').on('ifChanged', function (event) {
      if (window['$']('.subcb1').filter(':checked').length == window['$']('.subcb1').length) {
        window['$']('#checkAll1').prop('checked', 'checked');
      } else {
        window['$']('#checkAll1').prop('checked', false);
      }
      window['$']('#checkAll1').iCheck('update');
    });
  }
}
